<?php

namespace App\Http\Admin\Controllers\Goods;

use App\Http\Controllers\Controller;
use App\Http\Models\FxgShopGoodsLogs;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;


class GoodsSuperviseController extends Controller
{

    public function index()
    {
        return view('goods.supervise_goods_list');
    }


    public function list(Request $request){

        $product_name =   $request->input('product_name') ?? '';
        $shop_id =   $request->input('shop_id') ?? [];
        $page_size =   $request->input('pageSize') ?? 50;
        $start_time =   $request->input('start_time') ?? date("Y-m-d H:i:s", strtotime("-2 hour"));
        $end_time =   $request->input('end_time') ?? date("Y-m-d H:i:s");

        $Modal  =   FxgShopGoodsLogs::whereNotNull('product_id');

        if(!empty($product_name)){
            $Modal  =   $Modal->where('product_name','like',"%".$product_name."%");
        }

        if(!empty($shop_id)){
            $Modal  =   $Modal->whereIn('shop_id',$shop_id);
        }


        $result  =   $Modal->whereBetween('created_at',[$start_time,$end_time])->orderBy('created_at','desc')->paginate($page_size)->toArray();

        return res('获取成功',$result);


    }


}